package com.zhonglz.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhonglz.commons.base.BaseService;
import com.zhonglz.commons.context.SpringContextUtil;
import com.zhonglz.model.BuSignInfo;
import com.zhonglz.service.PdfService;
import com.zhonglz.support.event.SealSignDataEvent;
import com.zhonglz.support.model.SealSignData;
import com.zhonglz.util.result.ResultUtils;

@Service
public class PdfServiceImpl extends BaseService implements PdfService{

	@Override
	@Transactional
	public ResultUtils signPdfInfo(SealSignData sealSignData) {
		try {
			BuSignInfo info = buSignInfoMapper.selectByPrimaryKey(sealSignData.getSignId());
			sealSignData.setBuSignInfo(info); 
			SealSignDataEvent sealSignDataEvent = new SealSignDataEvent(this, sealSignData);
			SpringContextUtil.getApplicationContext().publishEvent(sealSignDataEvent);
			return new ResultUtils(ResultUtils.CODE_SUCCESS,"签署成功！",sealSignDataEvent.getSealSignData().getSignBackFileUid());
		} catch (Exception e) {
			return new ResultUtils(ResultUtils.CODE_ERROR,e.getMessage());
		}
		
	}

}
